package com.group.yqxxb.Exception;

import com.alibaba.fastjson.JSONObject;
import com.group.yqxxb.eums.ResultEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
public class MyException extends Exception{
    private Integer code;

    private String msg;

    public MyException(ResultEnum resultEnum) {
        //super调用父类的构造函数
        super(resultEnum.getMsg());
        this.code = resultEnum.getCode();
        this.msg =resultEnum.getMsg();
    }
    public MyException(String errorMsg) {
        super(errorMsg);
        this.code = 10000;
        this.msg = errorMsg;
    }

    public MyException(JSONObject error){
        super(error.getString("desc"));
        this.code = error.getInteger("code");
        this.msg = error.getString("desc");
    }

}
